\(\int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx\) [48]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (warning: unable to verify)
   Maple [B] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [F]
   Giac [B] (verification not implemented)
   Mupad [F(-1)]

Optimal result

Integrand size = 17, antiderivative size = 54 \[ \int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\frac {\arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{\sqrt {a-b}}+\frac {\sqrt {a+b \cot ^2(x)} \tan (x)}{a} \]

[Out]

arctan(cot(x)*(a-b)^(1/2)/(a+b*cot(x)^2)^(1/2))/(a-b)^(1/2)+(a+b*cot(x)^2)^(1/2)*tan(x)/a

Rubi [A] (verified)

Time = 0.11 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.294, Rules used = {3751, 491, 12, 385, 209} \[ \int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\frac {\arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{\sqrt {a-b}}+\frac {\tan (x) \sqrt {a+b \cot ^2(x)}}{a} \]

[In]

Int[Tan[x]^2/Sqrt[a + b*Cot[x]^2],x]

[Out]

ArcTan[(Sqrt[a - b]*Cot[x])/Sqrt[a + b*Cot[x]^2]]/Sqrt[a - b] + (Sqrt[a + b*Cot[x]^2]*Tan[x])/a

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 385

Int[((a_) + (b_.)*(x_)^(n_))^(p_)/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Subst[Int[1/(c - (b*c - a*d)*x^n), x]
, x, x/(a + b*x^n)^(1/n)] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && EqQ[n*p + 1, 0] && IntegerQ[n]

Rule 491

Int[((e_.)*(x_))^(m_)*((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Simp[(e*x)^(m
+ 1)*(a + b*x^n)^(p + 1)*((c + d*x^n)^(q + 1)/(a*c*e*(m + 1))), x] - Dist[1/(a*c*e^n*(m + 1)), Int[(e*x)^(m +
n)*(a + b*x^n)^p*(c + d*x^n)^q*Simp[(b*c + a*d)*(m + n + 1) + n*(b*c*p + a*d*q) + b*d*(m + n*(p + q + 2) + 1)*
x^n, x], x], x] /; FreeQ[{a, b, c, d, e, p, q}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && LtQ[m, -1] && IntBino
mialQ[a, b, c, d, e, m, n, p, q, x]

Rule 3751

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
 :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[c*(ff/f), Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2
 + ff^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rubi steps \begin{align*} \text {integral}& = -\text {Subst}\left (\int \frac {1}{x^2 \left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (x)\right ) \\ & = \frac {\sqrt {a+b \cot ^2(x)} \tan (x)}{a}+\frac {\text {Subst}\left (\int \frac {a}{\left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (x)\right )}{a} \\ & = \frac {\sqrt {a+b \cot ^2(x)} \tan (x)}{a}+\text {Subst}\left (\int \frac {1}{\left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (x)\right ) \\ & = \frac {\sqrt {a+b \cot ^2(x)} \tan (x)}{a}+\text {Subst}\left (\int \frac {1}{1-(-a+b) x^2} \, dx,x,\frac {\cot (x)}{\sqrt {a+b \cot ^2(x)}}\right ) \\ & = \frac {\arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{\sqrt {a-b}}+\frac {\sqrt {a+b \cot ^2(x)} \tan (x)}{a} \\ \end{align*}

Mathematica [C] (warning: unable to verify)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.85 (sec) , antiderivative size = 134, normalized size of antiderivative = 2.48 \[ \int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\frac {\left (1+\frac {b \cot ^2(x)}{a}\right ) \sin ^2(x) \left (\frac {4 (a-b) \cos ^2(x) \left (a+b \cot ^2(x)\right ) \operatorname {Hypergeometric2F1}\left (2,2,\frac {5}{2},\frac {(a-b) \cos ^2(x)}{a}\right )}{3 a^2}+\frac {\arcsin \left (\sqrt {\frac {(a-b) \cos ^2(x)}{a}}\right ) \left (a+2 b \cot ^2(x)\right )}{a \sqrt {\frac {(a-b) \cos ^2(x) \left (a+b \cot ^2(x)\right ) \sin ^2(x)}{a^2}}}\right ) \tan (x)}{\sqrt {a+b \cot ^2(x)}} \]

[In]

Integrate[Tan[x]^2/Sqrt[a + b*Cot[x]^2],x]

[Out]

((1 + (b*Cot[x]^2)/a)*Sin[x]^2*((4*(a - b)*Cos[x]^2*(a + b*Cot[x]^2)*Hypergeometric2F1[2, 2, 5/2, ((a - b)*Cos
[x]^2)/a])/(3*a^2) + (ArcSin[Sqrt[((a - b)*Cos[x]^2)/a]]*(a + 2*b*Cot[x]^2))/(a*Sqrt[((a - b)*Cos[x]^2*(a + b*
Cot[x]^2)*Sin[x]^2)/a^2]))*Tan[x])/Sqrt[a + b*Cot[x]^2]

Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(282\) vs. \(2(46)=92\).

Time = 0.91 (sec) , antiderivative size = 283, normalized size of antiderivative = 5.24

method result size
default \(\frac {\sqrt {4}\, \left (\sqrt {-\frac {a \cos \left (x \right )^{2}-\cos \left (x \right )^{2} b -a}{\left (\cos \left (x \right )+1\right )^{2}}}\, \ln \left (4 \cos \left (x \right ) \sqrt {-a +b}\, \sqrt {-\frac {a \cos \left (x \right )^{2}-\cos \left (x \right )^{2} b -a}{\left (\cos \left (x \right )+1\right )^{2}}}-4 \cos \left (x \right ) a +4 b \cos \left (x \right )+4 \sqrt {-a +b}\, \sqrt {-\frac {a \cos \left (x \right )^{2}-\cos \left (x \right )^{2} b -a}{\left (\cos \left (x \right )+1\right )^{2}}}\right ) a \cot \left (x \right )+\sqrt {-a +b}\, a \tan \left (x \right )+\sqrt {-a +b}\, b \cot \left (x \right )+\sqrt {-\frac {a \cos \left (x \right )^{2}-\cos \left (x \right )^{2} b -a}{\left (\cos \left (x \right )+1\right )^{2}}}\, \ln \left (4 \cos \left (x \right ) \sqrt {-a +b}\, \sqrt {-\frac {a \cos \left (x \right )^{2}-\cos \left (x \right )^{2} b -a}{\left (\cos \left (x \right )+1\right )^{2}}}-4 \cos \left (x \right ) a +4 b \cos \left (x \right )+4 \sqrt {-a +b}\, \sqrt {-\frac {a \cos \left (x \right )^{2}-\cos \left (x \right )^{2} b -a}{\left (\cos \left (x \right )+1\right )^{2}}}\right ) a \csc \left (x \right )\right )}{2 a \sqrt {-a +b}\, \sqrt {a +b \cot \left (x \right )^{2}}}\) \(283\)

[In]

int(tan(x)^2/(a+b*cot(x)^2)^(1/2),x,method=_RETURNVERBOSE)

[Out]

1/2*4^(1/2)/a/(-a+b)^(1/2)/(a+b*cot(x)^2)^(1/2)*((-(a*cos(x)^2-cos(x)^2*b-a)/(cos(x)+1)^2)^(1/2)*ln(4*cos(x)*(
-a+b)^(1/2)*(-(a*cos(x)^2-cos(x)^2*b-a)/(cos(x)+1)^2)^(1/2)-4*cos(x)*a+4*b*cos(x)+4*(-a+b)^(1/2)*(-(a*cos(x)^2
-cos(x)^2*b-a)/(cos(x)+1)^2)^(1/2))*a*cot(x)+(-a+b)^(1/2)*a*tan(x)+(-a+b)^(1/2)*b*cot(x)+(-(a*cos(x)^2-cos(x)^
2*b-a)/(cos(x)+1)^2)^(1/2)*ln(4*cos(x)*(-a+b)^(1/2)*(-(a*cos(x)^2-cos(x)^2*b-a)/(cos(x)+1)^2)^(1/2)-4*cos(x)*a
+4*b*cos(x)+4*(-a+b)^(1/2)*(-(a*cos(x)^2-cos(x)^2*b-a)/(cos(x)+1)^2)^(1/2))*a*csc(x))

Fricas [A] (verification not implemented)

none

Time = 0.33 (sec) , antiderivative size = 229, normalized size of antiderivative = 4.24 \[ \int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\left [-\frac {a \sqrt {-a + b} \log \left (-\frac {a^{2} \tan \left (x\right )^{4} - 2 \, {\left (3 \, a^{2} - 4 \, a b\right )} \tan \left (x\right )^{2} + a^{2} - 8 \, a b + 8 \, b^{2} + 4 \, {\left (a \tan \left (x\right )^{3} - {\left (a - 2 \, b\right )} \tan \left (x\right )\right )} \sqrt {-a + b} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}}}{\tan \left (x\right )^{4} + 2 \, \tan \left (x\right )^{2} + 1}\right ) - 4 \, {\left (a - b\right )} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )}{4 \, {\left (a^{2} - a b\right )}}, \frac {\sqrt {a - b} a \arctan \left (\frac {2 \, \sqrt {a - b} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )}{a \tan \left (x\right )^{2} - a + 2 \, b}\right ) + 2 \, {\left (a - b\right )} \sqrt {\frac {a \tan \left (x\right )^{2} + b}{\tan \left (x\right )^{2}}} \tan \left (x\right )}{2 \, {\left (a^{2} - a b\right )}}\right ] \]

[In]

integrate(tan(x)^2/(a+b*cot(x)^2)^(1/2),x, algorithm="fricas")

[Out]

[-1/4*(a*sqrt(-a + b)*log(-(a^2*tan(x)^4 - 2*(3*a^2 - 4*a*b)*tan(x)^2 + a^2 - 8*a*b + 8*b^2 + 4*(a*tan(x)^3 -
(a - 2*b)*tan(x))*sqrt(-a + b)*sqrt((a*tan(x)^2 + b)/tan(x)^2))/(tan(x)^4 + 2*tan(x)^2 + 1)) - 4*(a - b)*sqrt(
(a*tan(x)^2 + b)/tan(x)^2)*tan(x))/(a^2 - a*b), 1/2*(sqrt(a - b)*a*arctan(2*sqrt(a - b)*sqrt((a*tan(x)^2 + b)/
tan(x)^2)*tan(x)/(a*tan(x)^2 - a + 2*b)) + 2*(a - b)*sqrt((a*tan(x)^2 + b)/tan(x)^2)*tan(x))/(a^2 - a*b)]

Sympy [F]

\[ \int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\int \frac {\tan ^{2}{\left (x \right )}}{\sqrt {a + b \cot ^{2}{\left (x \right )}}}\, dx \]

[In]

integrate(tan(x)**2/(a+b*cot(x)**2)**(1/2),x)

[Out]

Integral(tan(x)**2/sqrt(a + b*cot(x)**2), x)

Maxima [F]

\[ \int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\int { \frac {\tan \left (x\right )^{2}}{\sqrt {b \cot \left (x\right )^{2} + a}} \,d x } \]

[In]

integrate(tan(x)^2/(a+b*cot(x)^2)^(1/2),x, algorithm="maxima")

[Out]

integrate(tan(x)^2/sqrt(b*cot(x)^2 + a), x)

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 216 vs. \(2 (46) = 92\).

Time = 0.34 (sec) , antiderivative size = 216, normalized size of antiderivative = 4.00 \[ \int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\frac {{\left (a \log \left (-a - 2 \, \sqrt {-a + b} \sqrt {b} + 2 \, b\right ) + \sqrt {-a + b} \sqrt {b} \log \left (-a - 2 \, \sqrt {-a + b} \sqrt {b} + 2 \, b\right ) - b \log \left (-a - 2 \, \sqrt {-a + b} \sqrt {b} + 2 \, b\right ) + 2 \, a - 2 \, b\right )} \mathrm {sgn}\left (\sin \left (x\right )\right )}{2 \, {\left (a \sqrt {-a + b} - a \sqrt {b} - \sqrt {-a + b} b + b^{\frac {3}{2}}\right )}} - \frac {\frac {\log \left ({\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2}\right )}{\sqrt {-a + b}} + \frac {4 \, \sqrt {-a + b}}{{\left (\sqrt {-a + b} \cos \left (x\right ) - \sqrt {-a \cos \left (x\right )^{2} + b \cos \left (x\right )^{2} + a}\right )}^{2} - a}}{2 \, \mathrm {sgn}\left (\sin \left (x\right )\right )} \]

[In]

integrate(tan(x)^2/(a+b*cot(x)^2)^(1/2),x, algorithm="giac")

[Out]

1/2*(a*log(-a - 2*sqrt(-a + b)*sqrt(b) + 2*b) + sqrt(-a + b)*sqrt(b)*log(-a - 2*sqrt(-a + b)*sqrt(b) + 2*b) -
b*log(-a - 2*sqrt(-a + b)*sqrt(b) + 2*b) + 2*a - 2*b)*sgn(sin(x))/(a*sqrt(-a + b) - a*sqrt(b) - sqrt(-a + b)*b
 + b^(3/2)) - 1/2*(log((sqrt(-a + b)*cos(x) - sqrt(-a*cos(x)^2 + b*cos(x)^2 + a))^2)/sqrt(-a + b) + 4*sqrt(-a
+ b)/((sqrt(-a + b)*cos(x) - sqrt(-a*cos(x)^2 + b*cos(x)^2 + a))^2 - a))/sgn(sin(x))

Mupad [F(-1)]

Timed out. \[ \int \frac {\tan ^2(x)}{\sqrt {a+b \cot ^2(x)}} \, dx=\int \frac {{\mathrm {tan}\left (x\right )}^2}{\sqrt {b\,{\mathrm {cot}\left (x\right )}^2+a}} \,d x \]

[In]

int(tan(x)^2/(a + b*cot(x)^2)^(1/2),x)

[Out]

int(tan(x)^2/(a + b*cot(x)^2)^(1/2), x)